//
//  SPActivityView.m
//  QRCodeDemo
//
//  Created by zhoutl on 14-8-13.
//  Copyright (c) 2014年 suning. All rights reserved.
//
#import "ScanActivityView.h"
@implementation ScanActivityView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code        
        [self addSubview:self.activityView];
        
        [self addSubview:self.messageTitle];
        
        self.messageTitle.center = CGPointMake(self.width/2, self.activityView.bottom+20);
        
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    }
    return self;
}



- (UILabel *)messageTitle
{
    if (!_messageTitle) {
        
        _messageTitle = [[UILabel alloc] init];
        
        _messageTitle.backgroundColor = [UIColor clearColor];
        
        _messageTitle.frame = CGRectMake(0,0, self.width, 34);
        
        _messageTitle.textAlignment = NSTextAlignmentCenter;
        
        _messageTitle.textColor = [UIColor whiteColor];
        
        _messageTitle.numberOfLines = 0;
        
        _messageTitle.text = @"正在加载...";
        
        _messageTitle.font = [UIFont fontWithName:HeitiBold size:16];
                
    }
    
    return _messageTitle;
}


- (UIActivityIndicatorView *)activityView
{
    if (!_activityView) {
        
        _activityView= [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
        
        _activityView.center = CGPointMake(self.width/2, self.height/2-60);
        
        _activityView.hidesWhenStopped=YES;
        
        [_activityView startAnimating];
    }
    
    return _activityView;
}


- (void)startActivityViewAnimating
{
    [self.activityView startAnimating];
}


- (void)stopActivityViewAnimating
{
    [self.activityView stopAnimating];
}
@end
